# Based on http://agilewebdevelopment.com/plugins/activerecord_base_without_table code
class BaseWithoutTable < ActiveRecord::Base
  self.abstract_class = true

  def create_or_update
    errors.empty?
  end

  class << self
    def columns()
      @columns ||= []
    end

    def column(name, sql_type = nil, default = nil, null = true)
      columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
    end
  end
end

class Maximum < BaseWithoutTable
  column :summary, :string
  validates_word_count :summary, :maximum => 3
end

class Minimum < BaseWithoutTable
  column :summary, :string
  validates_word_count :summary, :minimum => 3
end

class IntRange < BaseWithoutTable
  column :summary, :text
  validates_word_count :summary, :in => 3..5
end

class IntRangeExcludedEnd < BaseWithoutTable
  column :summary, :text
  validates_word_count :summary, :in => 3...5
end

class IntRangeIntRangeWithOverridenMessage < BaseWithoutTable
  column :summary, :text
  validates_word_count :summary, :in => 3...5, :message => 'Overriden message: %d/%d'
end

